﻿<phone:PhoneApplicationPage 
    x:Class="TencentWeiboSample.TimelineView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:converter="clr-namespace:TencentWeiboSample.Converter"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="696" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True" Loaded="PhoneApplicationPage_Loaded">

    <UserControl.Resources>

        <converter:StatusNameAndTextConverter x:Key="StatusNameAndTextConverter"/>

        <Style x:Key="TimelineStyle" TargetType="ListBoxItem">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="BorderBrush" Value="Transparent"/>
            <Setter Property="Padding" Value="0"/>
            <Setter Property="HorizontalContentAlignment" Value="Left"/>
            <Setter Property="VerticalContentAlignment" Value="Top"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <Border x:Name="LayoutRoot" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
                            <ContentControl x:Name="ContentContainer" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="0 10 0 0" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}">
                                <Grid MinWidth="420">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <!--<RowDefinition Height="Auto" />-->
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="60"/>
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <Grid HorizontalAlignment="Left" Height="75" Margin="0,5,0,0" VerticalAlignment="Top" >
                                        <Image Margin="0,5,0,0"  Stretch="None" Source="{Binding Head}"  HorizontalAlignment="Left" VerticalAlignment="Top" />
                                    </Grid>

                                    <TextBlock Text="{Binding Nick}" HorizontalAlignment="Left" Margin="0,10,0,0" VerticalAlignment="Top" Grid.Column="1"/>
                                    <TextBlock TextWrapping="Wrap" Grid.Column="1" Width="340" Text="{Binding Text}" Margin="0,50,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Top"/>

                                    <StackPanel Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left" Margin="14,10,10,10">
                                        <TextBlock TextWrapping="Wrap"  VerticalAlignment="Top" Width="340" Text="{Binding Source, Converter={StaticResource StatusNameAndTextConverter}}"/>
                                    </StackPanel>

                                </Grid>
                            </ContentControl>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <StackPanel Orientation="Horizontal">
            <TextBlock  Text="{Binding User.Nick}" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock Text="{Binding User.Location}" Margin="20,0,0,0" />
            </StackPanel>
            <TextBlock  Text="时间线" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <ListBox Height="550" ItemContainerStyle="{StaticResource TimelineStyle}" ItemsSource="{Binding Timeline}" HorizontalAlignment="Left" Margin="-12,6,0,0" Name="listBox1" VerticalAlignment="Top" Width="468" />
        </Grid>
        <Grid.Background>
            <ImageBrush />
        </Grid.Background>
    </Grid>

    <!--Sample code showing usage of ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="False">
            <shell:ApplicationBarIconButton IconUri="/Resources/appbar.edit.png" x:Name="postNewButton" Text="分享" Click="postNewButton_Click" />
            <shell:ApplicationBarIconButton IconUri="/Resources/appbar.refresh.png" Text="刷新" x:Name="refreshMenuButton" Click="ApplicationBarIconButton_Click" />
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>
